package com.qq.proxy.staticproxy;

import com.qq.business.OrderService;
import com.qq.business.impl.OrderServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Bob
 */
public class OrderServiceProxy implements OrderService {

    private static final Logger log = LoggerFactory.getLogger(OrderServiceProxy.class);
    private final OrderServiceImpl orderServiceImpl;

    public OrderServiceProxy(OrderServiceImpl orderServiceImpl) {
        this.orderServiceImpl = orderServiceImpl;
    }

    @Override
    public void generate() throws Exception {
        long startTime = System.currentTimeMillis();
        orderServiceImpl.generate();
        long endTime = System.currentTimeMillis();
        log.info("订单生成耗时：{}ms", endTime - startTime);
    }

    @Override
    public void detail() {
        long startTime = System.currentTimeMillis();
        orderServiceImpl.detail();
        long endTime = System.currentTimeMillis();
        log.info("订单详情耗时：{}ms", endTime - startTime);
    }

    @Override
    public void modify() {
        long startTime = System.currentTimeMillis();
        orderServiceImpl.modify();
        long endTime = System.currentTimeMillis();
        log.info("订单修改耗时：{}ms", endTime - startTime);
    }

    @Override
    public void delete() {

    }
}
